import { RequestUtil } from '@/utils/request.js';

const getList = (pageNo, pageSize, searchQuery, sortBy, isAsc) => {
  return RequestUtil.get('/storage', {
    params: {
      pageNo: pageNo,
      pageSize: pageSize,
      sortBy: sortBy,
      isAsc: isAsc,
      ...searchQuery
    }
  });
};

const add = (data) => {
  return RequestUtil.post('/storage', { data: data });
};

const update = (id, data) => {
  return RequestUtil.put('/storage', {
    data: { storageId: id, ...data }
  });
};

const deleteByIds = (ids) => {
  return RequestUtil.delete('/storage?ids=' + (Array.isArray(ids) ? ids.join(',') : ''));
};

export const StorageApi = {
  getList,
  add,
  update,
  deleteByIds
};
